package org.deng.vertx.springboot.config;


import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import org.deng.vertx.common.util.SnowFlake;


/**
 * @author 邓力宾
 * @date 2021/4/13 14:30
 * @desc 自定义mybatis-plus 的 id生成器
 */
public class IdGenerator implements IdentifierGenerator {
    private final SnowFlake snowFlake;

    public IdGenerator(SnowFlake snowFlake) {
        this.snowFlake = snowFlake;
    }

    @Override
    public Number nextId(Object entity) {
        return snowFlake.nextId();
    }

    @Override
    public String nextUUID(Object entity) {
        return snowFlake.nextId() + "";
    }
}
